﻿using System;
using System.Windows.Forms;

namespace Rename.UC.组合
{
    public partial class Uc右操作框 : UserControl
    {
        private EventHandler<NewFileNameTextChangedEventArgs> _newFileNameTextChanged=null;

        public Uc右操作框()
        {
            InitializeComponent();
        }

        public Uc大小写转换 Uc大小写转换
        {
            get => uc大小写转换;
        }

        #region 自定义事件
        public event EventHandler<NewFileNameTextChangedEventArgs> NewFileNameTextChanged
        {
            add { _newFileNameTextChanged += value; }
            remove { _newFileNameTextChanged -= value; }
        }
        protected virtual void OnNewFileNameTextChanged(NewFileNameTextChangedEventArgs e)
        {
            EventHandler<NewFileNameTextChangedEventArgs> temp = System.Threading.Volatile.Read(ref _newFileNameTextChanged);
            if (temp != null)
            {
                temp(this, e);
            }
        }
        #endregion

        #region 界面事件
        private void Uc右操作框_Load(object sender, EventArgs e)
        {
            if (this.ucTcMain.SelectedTab.VerticalScroll.Visible == true)
            {
                hr1.Width = this.ucTcMain.TabPages[0].Width - 17;
                hr2.Width = this.ucTcMain.TabPages[0].Width - 17;

                hr3.Width = this.ucTcMain.TabPages[1].Width - 17;
                hr4.Width = this.ucTcMain.TabPages[1].Width - 17;

                hr5.Width = this.ucTcMain.TabPages[2].Width - 17;
                hr6.Width = this.ucTcMain.TabPages[2].Width - 17;
                hr7.Width = this.ucTcMain.TabPages[2].Width - 17;

                hr8.Width = this.ucTcMain.TabPages[3].Width - 17;
                hr9.Width = this.ucTcMain.TabPages[3].Width - 17;
            }
            else
            {
                hr1.Width = this.ucTcMain.TabPages[0].Width;
                hr2.Width = this.ucTcMain.TabPages[0].Width;

                hr3.Width = this.ucTcMain.TabPages[1].Width;
                hr4.Width = this.ucTcMain.TabPages[1].Width;

                hr5.Width = this.ucTcMain.TabPages[2].Width;
                hr6.Width = this.ucTcMain.TabPages[2].Width;
                hr7.Width = this.ucTcMain.TabPages[2].Width;

                hr8.Width = this.ucTcMain.TabPages[3].Width;
                hr9.Width = this.ucTcMain.TabPages[3].Width;
            }
        }

        private void ucTcMain_SizeChanged(object sender, EventArgs e)
        {
            if (this.ucTcMain.SelectedTab.VerticalScroll.Visible == true)
            {
                hr1.Width = this.ucTcMain.TabPages[0].Width - 17;
                hr2.Width = this.ucTcMain.TabPages[0].Width - 17;

                hr3.Width = this.ucTcMain.TabPages[1].Width - 17;
                hr4.Width = this.ucTcMain.TabPages[1].Width - 17;

                hr5.Width = this.ucTcMain.TabPages[2].Width - 17;
                hr6.Width = this.ucTcMain.TabPages[2].Width - 17;
                hr7.Width = this.ucTcMain.TabPages[2].Width - 17;

                hr8.Width = this.ucTcMain.TabPages[3].Width - 17;
                hr9.Width = this.ucTcMain.TabPages[3].Width - 17;
            }
            else
            {
                hr1.Width = this.ucTcMain.TabPages[0].Width;
                hr2.Width = this.ucTcMain.TabPages[0].Width;

                hr3.Width = this.ucTcMain.TabPages[1].Width;
                hr4.Width = this.ucTcMain.TabPages[1].Width;

                hr5.Width = this.ucTcMain.TabPages[2].Width;
                hr6.Width = this.ucTcMain.TabPages[2].Width;
                hr7.Width = this.ucTcMain.TabPages[2].Width;

                hr8.Width = this.ucTcMain.TabPages[3].Width;
                hr9.Width = this.ucTcMain.TabPages[3].Width;
            }
        }

        private void txtNewFileName_TextChanged(object sender, EventArgs e)
        {
            OnNewFileNameTextChanged(new NewFileNameTextChangedEventArgs() { NewFileName = txtNewFileName.Text.Trim() });
        }
        #endregion

    }
}
